package com.linxz.wandnroid.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.linxz.wandnroid.appui.ProjectListFragment;
import com.linxz.wandnroid.pojo.Category;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Linxz
 * 创建日期：2020年02月29日 10:26
 * version：v4.5.4
 * 描述：
 */
public class ProjectFragAdapter extends FragmentPagerAdapter {

    private List<Category> categories = new ArrayList<>();

    public ProjectFragAdapter(FragmentManager fm, List<Category> categories) {
        super(fm);
        this.categories.addAll(categories);
    }

    @Override
    public Fragment getItem(int position) {
        ProjectListFragment frag=new ProjectListFragment();
        frag.setId(categories.get(position).getId());
        return frag;
    }

    @Override
    public int getCount() {
        return categories == null ? 0 : categories.size();
    }
}
